package com.company.dcm.server.tcp;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.util.AttributeKey;


public class MainChannelInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {

            // 设置端口标识
        socketChannel.attr(AttributeKey.valueOf("PORT_TYPE")).set("MAIN");

        ChannelPipeline pipeline = socketChannel.pipeline();
        // 添加通用处理器
        pipeline.addLast(new IdleStateHandler(30, 0, 0));
        // OTA专用处理器
        pipeline.addLast(new NettyServerHandler());
    }

}
